<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title> - 登录</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="favicon.ico">
    <link href="./admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="./admin/css/font-awesome.css?v=4.4.0" rel="stylesheet">

    <link href="./admin/css/animate.css" rel="stylesheet">
    <link href="./admin/css/style.css?v=4.1.0" rel="stylesheet">
    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html" />
    <![endif]-->
    <!-- <script>if (window.top !== window.self) { window.top.location = window.location; }</script> -->
    <style>
        #bg {
            position: absolute;
            top: 350px;
            left: 80px;
            z-index: -10;
        }
    </style>
</head>

<body class="gray-bg">

    <div class="middle-box text-center loginscreen  animated fadeInDown">
        <div id="fo">
            <div id="bg">
                <img src="./img/falali.png" alt="" id="beijing">
            </div>
            <h1 class="logo-name">h</h1>
            <h3>欢迎使用 hAdmin</h3>

            <div class="form-group">
                <input type="text" class="form-control" placeholder="用户名" required="" id="txtUserName">
            </div>
            <div class="form-group">
                <input type="password" class="form-control" placeholder="密码" required="" id="txtPassword">
            </div>
            <button onclick="loginHandle()" class="btn btn-success btn-block">
                登录
            </button>
            <p class="text-muted text-center"> <a href="login.html#"><small>忘记密码了？</small></a> | <a
                    href="register.html">注册一个新账号</a>
            </p>

        </div>
    </div>

    <!-- 全局js -->
    <script src="/admin/js/jquery.min.js"></script>

    <script>
        function loginHandle() {
            if ($("#txtUserName").val() && $("#txtPassword").val()) {
                $.ajax({
                    url: "/api/login",
                    data: {
                        username: $("#txtUserName").val(),
                        password: $("#txtPassword").val(),
                    },
                    type: "POST",
                    success(res) {
                        console.log(res);
                        if (res.code == 1) {
                            alert(res.msg)
                            window.location.href = "/";
                        } else {
                            alert(res.msg);
                        }
                    },
                });
            } else {
                alert("请输入登录信息");
            }
        }
    </script>

</body>

</html>